<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 封装
        class Animal {
            constructor(name,sex){
                this.name=name;
                this.sex=sex;
            }
            hi(){
                console.log("姓名:"+this.name+"性别:"+this.sex);
            }
        }
        // 继承多态
        class Dog extends Animal {
            hi(){
                console.log("姓名:"+this.name+"性别:"+this.sex);
            }
        }

        class Cat extends Animal {
            hi(){
                console.log("姓名:"+this.name+"性别:"+this.sex);
            }
        }

        var dog=new Dog("旺财","男");
        dog.hi();

        var cat=new Cat("汤姆","男");
        cat.hi();
        
    </script>
</body>
</html>